﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Happy.ExtentionMethods;

namespace Happy.Query.Filters
{
    /// <summary>
    /// 筛选器。
    /// </summary>
    public sealed class Filter : IFilter
    {
        /// <summary>
        /// 构造方法。
        /// </summary>
        public Filter(Connector connector, string property, Operator @operator, Operand[] operands)
        {
            property.MustNotNullAndNotWhiteSpace("property");
            operands.MustNotEmpty("operands");

            this.Connector = connector;
            this.Property = property;
            this.Operator = @operator;
            this.Operands = operands;
        }

        /// <summary>
        /// 连接器。
        /// </summary>
        public Connector Connector { get; private set; }

        /// <summary>
        /// 属性。
        /// </summary>
        public string Property { get; private set; }

        /// <summary>
        /// 运算符。
        /// </summary>
        public Operator Operator { get; private set; }

        /// <summary>
        /// 运算数。
        /// </summary>
        public Operand[] Operands { get; private set; }

        /// <inheritdoc />
        public void Accept(IFilterVisitor visitor)
        {
            visitor.Visit(this);
        }
    }
}
